<!DOCTYPE HTML>
	<html>
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8">
		<title>Sockettester</title>
		<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" charset="utf-8">
		
			
			var ws = null;
			var host = "localhost"
			var port = 8080
			var socket = "p5websocket"
			
			function ready(){
				console.log("trying to open a websocket")
				var _socket = (undefined==socket)?"":"/"+socket
				ws = new WebSocket("ws://"+host+":"+port+_socket)
				// When the connection is open, send some data to the server
				ws.onopen = function () {
				  console.log("opened")
				  ws.send('Ping'); // Send the message 'Ping' to the server
				};

				// oh, it did close
				ws.onerror = function (e) {
				  console.log('WebSocket did close ',e);
				};
				
				// Log errors
				ws.onerror = function (error) {
				  console.log('WebSocket Error ' + error);
				};

				// Log messages from the server
				ws.onmessage = function (e) {
				  $('#log').text(e.data+$('#log').text())
				  console.log('Server: ' + e.data);
				};
			}
						
			document.addEventListener("DOMContentLoaded", ready, false);
		</script>
	</head>
	<body>
		<div id="test-target">
			
		</div>
		<div id="log">
			
		</div>
	</body>
	</html>